package com.shse.dao;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;


@Repository
public class JdbcTemplateDao {

	private JdbcTemplate jdbcTemplate;
	
	@Autowired
	public void setDataSource(DataSource ds){
		this.jdbcTemplate = new JdbcTemplate(ds);
	}
	
	
	public void delMoney(Long userId, double count){
		jdbcTemplate.update("update UserBalance set balance=balance-? where userId=?", count, userId);
	}
	
	public void addMoney(Long userId, double count){
		jdbcTemplate.update("update UserBalance set balance=balance+? where userId=?", count, userId);
	}
}
